home *** CD-ROM | disk | FTP | other *** search
- /* ################################################################## */
- /*
- * Drop Menus : A Sick Hack
- *
- * Drop Menus is an attempt at providing Windows-like drop-menus in
- * the Macintosh environment. It is loosely based on "Auto Menus" by
- * Michael J. Conrad, who kindly provided me the source to Auto Menus
- * version 2.0 to work with. Drop Menus eschews the VBL approach of
- * Auto Menus in favour of direct clicking on the menu bar.
- *
- * main() and GetRight() functions based on 'C' code by Michael Conrad
- * Drop Menus is Copyright 1991 by Richard Outerbridge (outer)
- * Compiled with Symantec's THINK C, Version 4.02
- *
- * Version History
- * 1.2.0 : 910313 - first cut with _WaitMouseDown
- * 1.2.2 : 910314 - Oops! Infinite loop. Changed to _FlushEvents (4)
- * 1.2.3 : 910315 - added _Delay, and _FlushEvents 6 and 6
- * 1.2.4 : 910321 - changed to _FlushEvents 6 and 2; added comments
- */
-
- #define StillDown 0xA973 /* _StillDown trap */
-
- long oldStillDown;
- unsigned char trigger;
- unsigned char lastSD;
- short menuRight;
-
- extern void main(void);
- extern void myStillDown(void);
- extern void PutMouse(void);
- extern short GetRight(void);
-
- /* ################################################################## */
-
- void main() {
- asm{
- movem.l d0/a0-a1/a4,-(a7)
- lea.l main,a4
- lea.l main,a0
- _RecoverHandle
- move.l a0,a1
- _HLock
- move.w d0,0x0220
- move.l a1,-(a7)
- _DetachResource
- move.w #StillDown,d0
- _GetTrapAddress
- move.l a0,oldStillDown
- lea.l myStillDown,a0
- move.w #StillDown,d0
- _SetTrapAddress
- clr.w trigger
- jsr GetRight
- move.w d0,menuRight
- movem.l (a7)+,d0/a0-a1/a4
- }
- }
-
- /* ################################################################### */
-
- short GetRight() {
- asm {
- link a6,#-10
- pea.l -8(a6)
- _GetPort
- move.l #0x006c,d0
- _NewPtr
- move.w d0,0x0220
- move.l a0,-4(a6)
- move.l a0,-(a7)
- _OpenPort
- move.l -4(a6),a0
- move.w 14(a0),-10(a6)
- move.l -4(a6),-(a7)
- _ClosePort
- move.l -4(a6),a0
- _DisposPtr
- move.w d0,0x0220
- move.l -8(a6),-(a7)
- _SetPort
- add.w #-100,-10(a6)
- move.w -10(a6),d0
- unlk a6
- }
- }
-
- /* ################################################################## */
-
- void myStillDown() {
- asm {
- move.l a4,-(a7)
- lea.l main,a4 ; Where are the globals?
- move.b trigger,d0 ; Are we already activated?
- bne.s @still
- ; Is the mouse in the menu bar?
- move.w 0x0baa,d0 ; MBarHeight
- subq.w #2,d0
- cmp.w 0x0828,d0 ; mouse Y (undocumented)
- ble.s @clear
- move.w 0x082a,d0 ; mouse X (undocumented)
- cmp.w menuRight,d0 ; To the right of the menus?
- bge.s @clear
- cmp.w #10,d0 ; To the left of the Apple?
- ble.s @clear
-
- moveq.l #0,d0
- move.w 0x02f2,d0 ; DoubleTime (lsw)
- lsr.w #2,d0 ; Divide by 4
- move.l d0,a0
- _Delay ; Wait till things settle
-
- moveq.l #6,d0
- _FlushEvents ; Clear all mouse downs & ups
- move.b #1,trigger ; Set the trigger
- @still:
- clr.w -(a7) ; Call the "real" routine
- move.l oldStillDown,a0
- jsr (a0)
- move.b (a7)+,d0 ; Are we really still down?
- bne.s @last ; Yes: return 1
- clr.w -(a7)
- _Button
- move.b (a7)+,d0 ; Is the Button still down?
- bne.s @notSD ; No: return 0
- move.b lastSD,d0 ; Were we really still down last time?
- beq.s @fixSD ; No: return 1 - else return 0
- @notSD:
- moveq.l #2,d0
- _FlushEvents ; Clear all lingering mouse downs
- clr.w trigger ; Reset the trigger & lastSD
- moveq.l #0,d0 ; Get set to return 0
- @sdown:
- move.l (a7)+,a4
- move.w d0,4(a7)
- rts
- @last:
- move.b #1,lastSD ; Set lastSd
- @fixSD:
- move.w #0x0100,d0 ; Get set to return 1
- bra.s @sdown
- @clear: ; Not in the menu bar
- move.l oldStillDown,a0
- move.l (a7)+,a4
- jmp (a0) ; Pass control to the "real" routine
- /* rts */
- }
- }
-
- /* ################################################################## */
-